package com.example.demo.config;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.concurrent.*;

/**
 * @author: Scott
 * @Description:
 * @Date: Create in 11:05 2018/1/27
 */
@Component
public class ConsumersThreadPool {


    static ThreadFactory factory = new ThreadFactoryBuilder()
            .setNameFormat("consumer-pool-%d").build();

    @Bean
    public ExecutorService getExecutorService() {
        return new ThreadPoolExecutor(10, 20, 30L, TimeUnit.SECONDS,
                new LinkedBlockingDeque<>(1024), factory, new ThreadPoolExecutor.AbortPolicy());

    }
}
